package com.helen.adapter;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.coorchice.library.SuperTextView;
import com.helen.entity.MyRecoveryDetailEntity;
import com.helen.entity.MyRecoveryEntity;
import com.helen.shopping.R;
import com.helen.utils.MyLog;

import java.util.List;


/**
 * Created by yang on 2018/5/2.
 */

public class MyRecoveryDetailListAdapter extends BaseQuickAdapter<MyRecoveryDetailEntity, BaseViewHolder> {

    private OnSetItemPaoListener onItemPaoListener;
    public MyRecoveryDetailListAdapter(List<MyRecoveryDetailEntity> data) {
        super(R.layout.item_my_recovery_detail, data);

    }


    @Override
    protected void convert(final BaseViewHolder helper, final MyRecoveryDetailEntity item) {
        try {
            TextView tvTime = (TextView) helper.getView(R.id.tv_time);
            TextView tvMoney1 = (TextView) helper.getView(R.id.tv_money1);
            TextView tvMoney2 = (TextView) helper.getView(R.id.tv_money2);
            TextView tvYear = (TextView) helper.getView(R.id.tv_year);
            TextView tvMoney3 = (TextView) helper.getView(R.id.tv_money3);
            SuperTextView tvGoOut = (SuperTextView) helper.getView(R.id.tv_go_out);

            tvTime.setText("购买时间: "+item.getCreateTime());
            tvMoney1.setText(item.getPayMoney()+"");
            tvMoney2.setText(item.getPaoqiMoney()+"");
            tvYear.setText(item.getDays()+"");
            tvMoney3.setText(item.getMoney()+"");
            tvGoOut.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                  if(onItemPaoListener!=null){
                      onItemPaoListener.setOnPaoListener(item,helper.getAdapterPosition());
                  }
                }
            });


        } catch (Exception e) {
            MyLog.e("yang", "设置我的回收车详情异常" + e.toString());
        }


    }
    public interface OnSetItemPaoListener {
        void setOnPaoListener(MyRecoveryDetailEntity myRecoveryDetailEntity, int position);
    }


    public void setOnItemPaoListener(OnSetItemPaoListener onItemPaoListener) {

        this.onItemPaoListener = onItemPaoListener;
    }

}
